Imports DevExpress.XtraGrid.Columns

Imports Phoenix.DataAccess

Namespace Forms.Controls

    Public Class EmployeeFieldEdit : Inherits FieldEditBase

#Region " Windows Form Designer generated code "

        Public Sub New()
            MyBase.New()

            'This call is required by the Windows Form Designer.
            InitializeComponent()
            'Add any initialization after the InitializeComponent() call
        End Sub

        'UserControl overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub

        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer

        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        Friend WithEvents PopupEdit As DevExpress.XtraEditors.PopupContainerEdit
        Friend WithEvents PopupControlEmployee As DevExpress.XtraEditors.PopupContainerControl
        Friend WithEvents EmployeeGridControl As DevExpress.XtraGrid.GridControl
        Friend WithEvents EmployeeGridView As DevExpress.XtraGrid.Views.Grid.GridView
        Friend WithEvents GridColumnEPicture As DevExpress.XtraGrid.Columns.GridColumn
        Friend WithEvents EmployeeIconRI As DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox
        Friend WithEvents GridColumnEFullName As DevExpress.XtraGrid.Columns.GridColumn
        Friend WithEvents SysColumn As DevExpress.XtraGrid.Columns.GridColumn
        Friend WithEvents ActiveColumn As DevExpress.XtraGrid.Columns.GridColumn
        Friend WithEvents OperatorColumn As DevExpress.XtraGrid.Columns.GridColumn
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.PopupEdit = New DevExpress.XtraEditors.PopupContainerEdit
            Me.PopupControlEmployee = New DevExpress.XtraEditors.PopupContainerControl
            Me.EmployeeGridControl = New DevExpress.XtraGrid.GridControl
            Me.EmployeeGridView = New DevExpress.XtraGrid.Views.Grid.GridView
            Me.GridColumnEPicture = New DevExpress.XtraGrid.Columns.GridColumn
            Me.EmployeeIconRI = New DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox
            Me.GridColumnEFullName = New DevExpress.XtraGrid.Columns.GridColumn
            Me.SysColumn = New DevExpress.XtraGrid.Columns.GridColumn
            Me.ActiveColumn = New DevExpress.XtraGrid.Columns.GridColumn
            Me.OperatorColumn = New DevExpress.XtraGrid.Columns.GridColumn
            CType(Me.PopupEdit.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.PopupControlEmployee.SuspendLayout()
            CType(Me.EmployeeGridControl, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me.EmployeeGridView, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me.EmployeeIconRI, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            '
            'PopupEdit
            '
            Me.PopupEdit.Dock = System.Windows.Forms.DockStyle.Fill
            Me.PopupEdit.Location = New System.Drawing.Point(0, 0)
            Me.PopupEdit.Name = "PopupEdit"
            '
            'PopupEdit.Properties
            '
            Me.PopupEdit.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
            Me.PopupEdit.Properties.PopupControl = Me.PopupControlEmployee
            Me.PopupEdit.Size = New System.Drawing.Size(280, 20)
            Me.PopupEdit.TabIndex = 2
            '
            'PopupControlEmployee
            '
            Me.PopupControlEmployee.Controls.Add(Me.EmployeeGridControl)
            Me.PopupControlEmployee.Location = New System.Drawing.Point(16, 104)
            Me.PopupControlEmployee.Name = "PopupControlEmployee"
            Me.PopupControlEmployee.Size = New System.Drawing.Size(256, 232)
            Me.PopupControlEmployee.TabIndex = 5
            '
            'EmployeeGridControl
            '
            Me.EmployeeGridControl.Dock = System.Windows.Forms.DockStyle.Fill
            '
            'EmployeeGridControl.EmbeddedNavigator
            '
            Me.EmployeeGridControl.EmbeddedNavigator.Name = ""
            Me.EmployeeGridControl.Location = New System.Drawing.Point(0, 0)
            Me.EmployeeGridControl.MainView = Me.EmployeeGridView
            Me.EmployeeGridControl.Name = "EmployeeGridControl"
            Me.EmployeeGridControl.RepositoryItems.AddRange(New DevExpress.XtraEditors.Repository.RepositoryItem() {Me.EmployeeIconRI})
            Me.EmployeeGridControl.Size = New System.Drawing.Size(256, 232)
            Me.EmployeeGridControl.TabIndex = 0
            Me.EmployeeGridControl.Text = "GridControl1"
            '
            'EmployeeGridView
            '
            Me.EmployeeGridView.Columns.AddRange(New DevExpress.XtraGrid.Columns.GridColumn() {Me.GridColumnEPicture, Me.GridColumnEFullName, Me.SysColumn, Me.ActiveColumn, Me.OperatorColumn})
            Me.EmployeeGridView.GridControl = Me.EmployeeGridControl
            Me.EmployeeGridView.Name = "EmployeeGridView"
            Me.EmployeeGridView.OptionsDetail.EnableMasterViewMode = False
            Me.EmployeeGridView.OptionsView.ShowGroupPanel = False
            Me.EmployeeGridView.OptionsView.ShowIndicator = False
            '
            'GridColumnEPicture
            '
            Me.GridColumnEPicture.ColumnEdit = Me.EmployeeIconRI
            Me.GridColumnEPicture.Name = "GridColumnEPicture"
            Me.GridColumnEPicture.Options = CType(((DevExpress.XtraGrid.Columns.ColumnOptions.ReadOnly Or DevExpress.XtraGrid.Columns.ColumnOptions.FixedWidth) _
                        Or DevExpress.XtraGrid.Columns.ColumnOptions.NonEditable), DevExpress.XtraGrid.Columns.ColumnOptions)
            Me.GridColumnEPicture.VisibleIndex = 0
            Me.GridColumnEPicture.Width = 20
            '
            'EmployeeIconRI
            '
            Me.EmployeeIconRI.AutoHeight = False
            Me.EmployeeIconRI.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
            Me.EmployeeIconRI.Items.AddRange(New Object() {New DevExpress.XtraEditors.Controls.ImageComboBoxItem("", Nothing, 4)})
            Me.EmployeeIconRI.Name = "EmployeeIconRI"
            '
            'GridColumnEFullName
            '
            Me.GridColumnEFullName.Caption = "Name :"
            Me.GridColumnEFullName.FieldName = "FullName"
            Me.GridColumnEFullName.Name = "GridColumnEFullName"
            Me.GridColumnEFullName.Options = CType(((((((((DevExpress.XtraGrid.Columns.ColumnOptions.CanFiltered Or DevExpress.XtraGrid.Columns.ColumnOptions.CanMoved) _
                        Or DevExpress.XtraGrid.Columns.ColumnOptions.CanGrouped) _
                        Or DevExpress.XtraGrid.Columns.ColumnOptions.CanResized) _
                        Or DevExpress.XtraGrid.Columns.ColumnOptions.CanSorted) _
                        Or DevExpress.XtraGrid.Columns.ColumnOptions.ReadOnly) _
                        Or DevExpress.XtraGrid.Columns.ColumnOptions.CanFocused) _
                        Or DevExpress.XtraGrid.Columns.ColumnOptions.ShowInCustomizationForm) _
                        Or DevExpress.XtraGrid.Columns.ColumnOptions.NonEditable), DevExpress.XtraGrid.Columns.ColumnOptions)
            Me.GridColumnEFullName.VisibleIndex = 1
            Me.GridColumnEFullName.Width = 234
            '
            'SysColumn
            '
            Me.SysColumn.Caption = "System"
            Me.SysColumn.FieldName = "Sys"
            Me.SysColumn.Name = "SysColumn"
            Me.SysColumn.Options = DevExpress.XtraGrid.Columns.ColumnOptions.CanFiltered
            '
            'ActiveColumn
            '
            Me.ActiveColumn.Caption = "Active"
            Me.ActiveColumn.FieldName = "IsAttendant"
            Me.ActiveColumn.Name = "ActiveColumn"
            '
            'OperatorColumn
            '
            Me.OperatorColumn.Caption = "Operator"
            Me.OperatorColumn.FieldName = "IsOperator"
            Me.OperatorColumn.Name = "OperatorColumn"
            Me.OperatorColumn.Options = DevExpress.XtraGrid.Columns.ColumnOptions.CanFiltered
            '
            'EmployeeFieldEdit
            '
            Me.Controls.Add(Me.PopupControlEmployee)
            Me.Controls.Add(Me.PopupEdit)
            Me.Name = "EmployeeFieldEdit"
            Me.Size = New System.Drawing.Size(280, 352)
            CType(Me.PopupEdit.Properties, System.ComponentModel.ISupportInitialize).EndInit()
            Me.PopupControlEmployee.ResumeLayout(False)
            CType(Me.EmployeeGridControl, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me.EmployeeGridView, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me.EmployeeIconRI, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)

        End Sub

#End Region

#Region " Field Editor Behavior "
        Public Overrides ReadOnly Property FieldView() As DevExpress.XtraEditors.PopupContainerEdit
            Get
                Return PopupEdit
            End Get
        End Property

        Public Overrides ReadOnly Property GridView() As DevExpress.XtraGrid.Views.Grid.GridView
            Get
                Return EmployeeGridView
            End Get
        End Property

        Public Overrides ReadOnly Property PrimaryColumn() As DevExpress.XtraGrid.Columns.GridColumn
            Get
                Return GridColumnEFullName
            End Get
        End Property


        Public Overrides ReadOnly Property Icon() As DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox
            Get
                Return EmployeeIconRI
            End Get
        End Property

        Public Overrides ReadOnly Property IconColumn() As DevExpress.XtraGrid.Columns.GridColumn
            Get
                Return GridColumnEPicture
            End Get
        End Property

        Public Overrides ReadOnly Property PopupWindow() As DevExpress.XtraEditors.PopupContainerControl
            Get
                Return PopupControlEmployee
            End Get
        End Property

        Public Sub UpdateFilters()
            Try
                SysColumn.FilterInfo = ColumnFilterInfo.Empty
                OperatorColumn.FilterInfo = ColumnFilterInfo.Empty
                If AppConfig.UserModeEnabled Then
                    SysColumn.FilterInfo = New ColumnFilterInfo(False)
                End If
                OperatorColumn.FilterInfo = New ColumnFilterInfo(True)
            Catch ex As Exception
                Debug.WriteLineIf(AppError, ex.ToString())
            End Try
        End Sub

#End Region

#Region " Event Handlers & Overridables"
        Private Sub Control_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If DesignMode Then Return

            EmployeeGridControl.DataSource = New DataView(AppDataLayer.Employees)

            UpdateFilters()
        End Sub


        Private Sub PopupEdit_FocusedRowChanged(ByVal Sender As Object, ByVal e As DevExpress.XtraEditors.Controls.QueryDisplayTextEventArgs) Handles PopupEdit.QueryDisplayText
            If e.EditValue Is Nothing Then
                e.DisplayText = Res.AppointmentSelectStaffMember
            Else
                e.DisplayText = CType(e.EditValue, DataSetData.Employee).FullName
            End If
        End Sub

        Public Overrides Sub UpdateConfiguration()
            MyBase.UpdateConfiguration()
            UpdateFilters()
        End Sub
#End Region
    End Class

End Namespace